var app = new Vue({
    el: "#app",
    data: {
        searchKey: '',
        ajax: true,
        api: true,
        select: {},
        data: [
        <#list docList as item>
            {
                "title": "${item.title?default('')}",
                "type": "${item.type}",
                "module": "${item.module?default('')}",
                "target": "${item.target?default('')}",
                "method": "${item.method?default('')}",
                "id": "ajax.${item.module}.${item.target}.${item.method}",
                "reqParams": [
                    <#list item.reqParams as param>
                    {
                        "name": "${param.name?default('')}",
                        "type": "${param.type?default('')}",
                        "required": ${param.required?c},
                        "note": "${param.note?default('')}"
                    },
                    </#list>
                ],
                "rspParams": [
                    <#list item.rspParams as param>
                    {
                        "name": "${param.name?default('')}",
                        "type": "${param.type?default('')}",
                        "note": "${param.note?default('')}"
                    },
                    </#list>
                ],
                "entList": [
                    <#list item.entParams as key,value>
                    {
                        "name": "${key}",
                        "entParams": [
                            <#list value.entParams as param>
                            {
                                "name": "${param.name?default('')}",
                                "type": "${param.type?default('')}",
                                "note": "${param.note?default('')}"
                            },
                            </#list>
                        ]
                    }
                    </#list>
                ]
            },
        </#list>
        ],
    },
    computed: {
        list: function () {
            return this.data.filter(function (item) {
                var f1 = this.searchKey ? item.title.match(new RegExp(this.searchKey, "ig")) : true;
                var f2 = this.ajax && item.type == "ajax";
                var f3 = this.api && item.type == "api";
                return f1 && (f2 || f3);
            }.bind(this));
        }
    },
    methods: {
        onSelect: function (item) {
            this.select = item;
        }
    }
});